set args = WScript.Arguments
if (args(0)="product") then 
	wscript.Stdout.WriteLine(GetProductVersion(args(1), args(2)))
else
	wscript.Stdout.WriteLine(GetFileVersion(args(1)))
end if

Function GetFileVersion(sFilePath)
	Set FSO = CreateObject("Scripting.FileSystemObject")
	GetFileVersion = FSO.GetFileVersion(sFilePath)
	Set FSO = nothing
End Function

Function GetProductVersion(sFilePath, sProgram)
Dim objShell, objFolder, objFolderItem, i 
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(sFilePath & "\" & sProgram) Then
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(sFilePath)
    Set objFolderItem = objFolder.ParseName(sProgram)
    Dim arrHeaders(300)
    For i = 0 To 300
        arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
        If lcase(arrHeaders(i))= "product version" Then
            GetProductVersion= objFolder.GetDetailsOf(objFolderItem, i)
            Exit For
        End If
    Next
End If
Set FSO = nothing
End Function